﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="listmaterial.aspx.cs" Inherits="lcgps.Web.gpsinfo.listmaterial" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <%--<script src="../Script/datetime.js"></script>--%>
    <script type="text/javascript">
        var pid = "";
        var pcid = "";
        var mid = "";
        $(function () {
            pid = getUrlParam('pid');
            pcid = getUrlParam('pcid');
            mid = getUrlParam('mid');
            InitGird();

        });
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '物料信息列表', //表格标题
                url: 'GetGPS.ashx', //请求数据的页面
                sortName: 'gdatetime', //排序字段
                idField: '', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                singleSelect: true,
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[
                    { title: '项目号', field: 'proid', width: 150 },
                { title: '订单号', field: 'purchaseid', width: 150 },
        { title: '物料编码', field: 'mbm', width: 150 },
        {
            title: '物料名称', field: 'material', width: 200

        },
                //{ title: '数量', field: 'nums', width: 150 },
        { title: '单位', field: 'unit', width: 150 },
        { title: '价格', field: 'unitPrice', width: 150 }

                ]],
                onLoadSuccess: function (data) {
                    if(data.total==0)
                        $.messager.alert("提示", "没有数据！", "info");
                },
                queryParams: { "action": "querym", "pid": pid, "pcid": pcid, "mid": mid },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 100, //默认一页数据条数
                pageList: [100],
                rownumbers: true //行号
            });


        }
        function getQueryParams(queryParams) {
            var StartTime = $("#StartTime").datebox("getValue");
            var EndTime = $("#EndTime").datebox("getValue");
            var pid = $("#pid").val();
            var pcid = $("#pcid").val();
            var mid = $("#mid").val();
            queryParams.StartTime = StartTime;
            queryParams.EndTime = EndTime;
            queryParams.pid = pid;
            queryParams.pcid = pcid;
            queryParams.mid = mid;

            return queryParams;

        }

        //增加查询参数，重新加载表格  
        function reloadgrid() {
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');
        }
        function removeUser() {
            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要删除的行！", "info");
            }
            if (row) {
                $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                    if (r) {
                        $('#fm').form('submit', {
                            url: 'GetCate.ashx?proid=' + row.proid + '&purchaseid=' + row.purchaseid + '&mid=' + row.mid + '&action=delete',
                            onSubmit: function () {
                                //return $(this).form('validate');  
                            },
                            success: function (result) {
                                if (result.indexOf("T") == 0) {
                                    $('#dlg').dialog('close');
                                    $('#tt').datagrid('clearSelections'); //清空选中的行  
                                    $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                    //alert('恭喜您，信息删除成功！')  
                                    // close the dialog  
                                    $('#tt').datagrid('reload');
                                    //$('#fm').form('submit');

                                }
                                else if ((result.indexOf("F") == 0)) {
                                    $.messager.alert("提示", "添加失败，请重新操作！", "info");
                                    return;
                                }
                                else if ((result.indexOf("L") == 0)) {
                                    $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                                    top.location = '/index.aspx';
                                    return;
                                }
                            }
                        });
                    }
                })
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="dlg" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlg-buttons',shadow:false">
        <form id="fm" method="post">
            <div class="fitem">
                <label>类别名称：</label>
                <input id="caname" name="caname" class="easyui-validatebox" data-options="required:true,validType:'length[1,8]'" />
                <input name="Test" id="test" type="hidden" />
                <input name="caid" id="caid" type="hidden" />
            </div>

        </form>
    </div>
    <div id="dlg-buttons">
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveUser()">保存</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
    </div>

</asp:Content>
